package com.xja.web.domain.service.impl;

import com.xja.web.domain.mapper.OrderInfoMapper;
import com.xja.web.domain.model.JsonBean;
import com.xja.web.domain.model.OrderInfo;
import com.xja.web.domain.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderInfoMapper order;
    @Override
    public void insertOrder(String orderid) {
        OrderInfo orderInfo = new OrderInfo();
        orderInfo.setOrderid(orderid);
        order.insert(orderInfo);
    }

    @Override
    public JsonBean selectOrder(String orderid) {
        OrderInfo orderInfo = order.selectByPrimaryKey(orderid);
        if (orderInfo!=null&&orderInfo.getStatus()==0){
            return  new JsonBean(-1,"未支付",null);
        }
        return  new JsonBean(0,"已支付",null);
    }

    @Override
    public JsonBean updateOrder(String orderid) {
        int i = order.updateByOrderId(orderid);
        if (i>0){
            return  new JsonBean(0,"修改成功",null);
        }
        return  new JsonBean(-1,"修改失败",null);
    }
}
